import { MenuModel } from '@/api/system/menu/MenuModel'
import { reactive } from 'vue'

export default function useBaseModel() {
    //表单绑定的数据
    const addModel = reactive<MenuModel>({
        id: 0,
        editType: '',
        type: '',
        parent_id: '',
        path: '',
        name: '',
        hidden: '',
        component: '',
        title: '',
        sort: 1,
        icon: '',
        code: '',
        keep_alive: '1',
        is_link: '',
        status: ''
    })
    //表单验证规则
    const rules = reactive({
        type: [
            {
                required: true,
                trigger: 'change',
                message: '请选择菜单类型'
            }
        ],
        parent_id: [
            {
                required: true,
                trigger: 'change',
                message: '请选择上级菜单'
            }
        ],
        title: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写展示名称'
            },
            { min: 2, max: 50, message: '长度为2-50个字符', trigger: 'blur' }
        ],
        // name: [
        //     {
        //         required: true,
        //         trigger: 'change',
        //         message: '请填写路由名称'
        //     }
        // ],
        path: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写路由路径'
            }
        ],
        hidden: [
            {
                required: true,
                trigger: 'change',
                message: '请选择是否在列表隐藏'
            }
        ],
        code: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写权限字段'
            }
        ],
        icon: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写图标'
            }
        ],
        component: [
            {
                required: true,
                trigger: 'blur',
                message: '请文件路径'
            }
        ]
    })

    return {
        addModel,
        rules
    }
}
